package com.saoft.leaves.common;

/**
 * 异步接口统一返回对象
 */
public class AjaxResult {

    /**
     * 一般code 为200代表成功 500代表错误。也有用0，1的根据项目组成员讨论决定
     */
    private int code;
    private String msg;
    private Object data;

    public static AjaxResult success() {
        AjaxResult result = new AjaxResult();
        result.setCode(200);
        return result;
    }

    public static AjaxResult error() {
        AjaxResult result = new AjaxResult();
        result.setCode(500);
        return result;
    }

    public int getCode() {
        return code;
    }

    public AjaxResult setCode(int code) {
        this.code = code;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public AjaxResult setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public Object getData() {
        return data;
    }

    public AjaxResult setData(Object data) {
        this.data = data;
        return this;
    }
}
